<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .container{
            width: 800px;
            height: 500px;
            border: 1px solid;
            margin: 100px auto;
            position: relative;
        }
        #box{
            width: 100px;
            height: 100px;
            background-color: #ccc;
            border-radius: 50%;
            position: absolute;
            left: 0;
            top: 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <div id="box"></div>
    </div>
</body>
<script>
    let box=document.querySelector("#box")
    document.addEventListener("keydown",function(e){
        let speed=e.shiftKey ? 15:5
        if(e.keyCode==37&& box.offsetLeft>0){
            box.style.left=box.offsetLeft - speed+"px"
        }else if(e.keyCode==38&& box.offsetTop>0){
            box.style.top=box.offsetTop - speed+"px"
        }else if(e.keyCode==39&& box.offsetLeft<700){
            box.style.left=box.offsetLeft + speed+"px"
        }else if(e.keyCode==40&& box.offsetTop<400){
            box.style.top=box.offsetTop + speed+"px"
        }
    })
</script>
</html>